/*
 * @Author: syyao 
 * @Date: 2019-05-17 15:23:38 
 * @Last Modified by: syyao
 * @Last Modified time: 2019-06-12 21:16:23
 */
<template>
    <Row style="height: 100%">
        <i-col
            span="5"
            class="scroll-hidden"
            style="height: 100%;background-color: #F6F6FA;box-shadow:6px 0px 6px #C2C2C2;position:fixed;overflow-x: scroll;white-space: nowrap;"
        >
            <second-mune name="个人仓库" :list="hubList"></second-mune>
        </i-col>
        <i-col span="5">
            <br>
        </i-col>
        <i-col span="19" style="height: 100%;">
            <div style="height: auto;width:87%;margin:0 auto;">
                <p
                    style="margin-top:1.8vw;font-size:1.2vw;color: #7A7A7A;font-family: DengXian"
                >个人仓库</p>
                <p
                    style="margin-top:0.1vw;font-size:2vw;color: #44519E;font-weight: bold;font-family: DengXian"
                >{{HubName}}</p>
                <div style="margin-top:0.6vw;width: 10vw;height: 0.2vw;background-color:#45529F"></div>
            </div>

            <div style="height: auto;width:87%;margin:0 auto;">
                <router-view></router-view>
            </div>
        </i-col>
    </Row>
</template>

<script>
import SecondMune from "../components/SecondMune";
export default {
  name: "PersonalHub",
  components: { SecondMune },
  created() {
    
    // if (this.$store.state.user.isLogin === false) {
    //   this.$Message.warning("请先登录");
    //   this.$router.push({
    //     name: "home"
    //   });
    //   this.$store.commit("setLoginFilter");
    //   return;
    // }

    this.http.post(this,'/isLogin')
    this.hubList = this.$store.state.user.Hub;
    this.targetFolder.PersonalHubId = this.$store.state.user.choosenPHubId;
    if (this.$route.params.HubId === undefined) {
      this.$router.push({
        name: "HubId",
        params: {
          HubId: this.hubList[0].id
        }
      });
    }
  },

  data() {
    return {
      hubList: [],
      targetFolder: {
        PersonalHubId: ""
      }
    };
  },
  watch: {
    "$store.state.user.Hub": function(newVal) {
      this.hubList = JSON.parse(JSON.stringify(newVal));
    },
    "$store.state.user.choosenPHubId": function(newVal) {
      this.targetFolder.PersonalHubId = newVal;
    }
  },
  updated() {
    if (this.$route.params.HubId === undefined) {
      this.$router.push({
        name: "HubId",
        params: {
          HubId: this.hubList[0].id
        }
      });
    }
  },
  computed: {
    HubName() {
      let temp;
      let list = JSON.parse(JSON.stringify(this.hubList));
      let id = this.targetFolder.PersonalHubId;
      temp = list.find(item => item.id === id);
      if (temp !== undefined) {
        return temp.personalHubname;
      }
    }
  },
  methods: {}
};
</script>

<style scoped>
.scroll-hidden::-webkit-scrollbar {
  display: none;
}
</style>